package com.pwc.deadletter;

import com.pwc.utils.RabbitUtil;
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * @author fantuancyh
 * @data 2021/8/21
 */
public class Provider {
    private static final String NORMAL_EXCHANGE = "normal_exchange";

    public static void main(String[] args) throws IOException, TimeoutException {
        Channel channel = RabbitUtil.makeChannel();
        // 消息由于到期
//        AMQP.BasicProperties basicProperties = new AMQP.BasicProperties().builder()
//                .expiration("10000").build();
        channel.exchangeDeclare(NORMAL_EXCHANGE, BuiltinExchangeType.DIRECT);
        for (int i = 1; i < 11; i++) {
            String str = "信息" + i;
            System.out.println("产生消息" + str);
            channel.basicPublish(NORMAL_EXCHANGE, "zhangsan", null, str.getBytes());

        }
    }
}
